//
//  userManager.m
//  田园
//
//  Created by lanou on 16/4/16.
//  Copyright © 2016年 lanou. All rights reserved.
//

#import "userManager.h"

static userManager *manager = nil;
@implementation userManager


+(userManager *)shareManger{
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        manager = [[userManager alloc] init];
    });
    return manager;
}

//用户ID
+(void) saveuserID:(NSString *)userID
{
    [[NSUserDefaults standardUserDefaults] setObject:userID forKey:@"userID"];
    [[NSUserDefaults standardUserDefaults] synchronize];
}
+(NSString *) getUsrID
{
    NSString *string = [[NSUserDefaults standardUserDefaults] objectForKey:@"userID"];
    if (string == nil) {
        return @" ";
    }return string;
}
//删除用户的ID
+(void) cancelUserID
{
    [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"userID"];
    [[NSUserDefaults standardUserDefaults] synchronize];
}

//用户手机号
+(void) saveserMobile:(NSString *)userMobile
{
    [[NSUserDefaults standardUserDefaults] setObject:userMobile forKey:@"userMobile"];
    [[NSUserDefaults standardUserDefaults] synchronize];
}
+(NSString *) getUsrMobile
{
    NSString *Mobile = [[NSUserDefaults standardUserDefaults] objectForKey:@"userMobile"];
    if (Mobile == nil) {
        return @" ";
    }return Mobile;
}

+(void) cancel:(NSString *)userMobile
{
    [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"userMobile"];
    [[NSUserDefaults standardUserDefaults] synchronize];
}



//用户密码
+(void) savePassWord:(NSString *)userPassWord
{
    [[NSUserDefaults standardUserDefaults] setObject:userPassWord forKey:@"userPassWord"];
    [[NSUserDefaults standardUserDefaults] synchronize];
}
+(NSString *) getUsrPassWord
{
    NSString *PassWord = [[NSUserDefaults standardUserDefaults] objectForKey:@"userPassWord"];
    if (PassWord == nil) {
        return @" ";
    }return PassWord;
}
//+(NSString *) changePassWord;

//用户城市
+(void) saveuserCity:(NSString *)userCity
{
    [[NSUserDefaults standardUserDefaults] setObject:userCity forKey:@"userCity"];
    [[NSUserDefaults standardUserDefaults] synchronize];
}

+(NSString *) getUsrCity
{
    NSString *UsrCity = [[NSUserDefaults standardUserDefaults] objectForKey:@"userCity"];
    if (UsrCity == nil) {
        return @" ";
    }return UsrCity;
}

//用户昵称
+(void) saveuserName:(NSString *)userName
{
    [[NSUserDefaults standardUserDefaults] setObject:userName forKey:@"userName"];
    [[NSUserDefaults standardUserDefaults] synchronize];
}
+(NSString *)getUsrName
{
    NSString *UsrName = [[NSUserDefaults standardUserDefaults] objectForKey:@"userName"];
    if (UsrName == nil) {
        return @" ";
    }return UsrName;
}

+(void) cancelUserName
{
    [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"userName"];
    [[NSUserDefaults standardUserDefaults] synchronize];
}

//用户性别
+(void) saveuserGender:(NSString *)userGender
{
    [[NSUserDefaults standardUserDefaults] setObject:userGender forKey:@"userGender"];
    [[NSUserDefaults standardUserDefaults] synchronize];
}
+(NSString *)getUsrGender
{
    NSString *UsrGender = [[NSUserDefaults standardUserDefaults] objectForKey:@"userGender"];
    if (UsrGender == nil) {
        return @" ";
    }return UsrGender;
}

//用户生日
+(void) saveuserBirthday:(NSString *)userBirthday
{
    [[NSUserDefaults standardUserDefaults] setObject:userBirthday forKey:@"userBirthday"];
    [[NSUserDefaults standardUserDefaults] synchronize];
}
+(NSString *)getUsrBirthday
{
    NSString *UsrBirthday = [[NSUserDefaults standardUserDefaults] objectForKey:@"userBirthday"];
    if (UsrBirthday == nil) {
        return @" ";
    }return UsrBirthday;
}


//用户签名
+(void) saveuserPersonalSignature:(NSString *)userPersonalSignature
{
    [[NSUserDefaults standardUserDefaults] setObject:userPersonalSignature forKey:@"userPersonalSignature"];
    [[NSUserDefaults standardUserDefaults] synchronize];
}
+(NSString *)getuserPersonalSignature
{
    NSString *string = [[NSUserDefaults standardUserDefaults] objectForKey:@"userPersonalSignature"];
    if (string == nil) {
        return @" ";
    }
    return string;
}



//用户头像
+(void) saveuserHeadImage:(UIImage *)userHeadImage
{
    NSData *data = UIImagePNGRepresentation(userHeadImage);
    [[NSUserDefaults standardUserDefaults] setObject:data forKey:@"userHeadImage"];
    [[NSUserDefaults standardUserDefaults] synchronize];
}
+(UIImage *)getUsrHeadImage
{
    NSData *data = [[NSUserDefaults standardUserDefaults] objectForKey:@"userHeadImage"];
    UIImage *image = [UIImage imageWithData:data];
    if (image == nil) {
        return nil;
    }
    return image;
}
+(void) cancelUserHeadImage
{
    [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"userHeadImage"];
    [[NSUserDefaults standardUserDefaults] synchronize];
}

@end
